Newer
Older
TheVengeance-Project-IADE-Unity2D / Assets / Scripts / NPC / Quest NPC / RangedArea.cs
@Rackday Rackday on 18 Aug 714 bytes Project Added
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RangedArea : MonoBehaviour
{
    [HideInInspector] public bool playerInRange;
    private PlayerController playerController;

    private void Start()
    {
        playerInRange = false;
        playerController = FindObjectOfType<PlayerController>();
    }

    private void OnTriggerEnter2D(Collider2D col)
    {
        if (col.CompareTag("Player"))
        {
            playerInRange = true;
        }
    }

    private void OnTriggerExit2D(Collider2D col)
    {
        if (col.CompareTag("Player"))
        {
            playerInRange = false;
            playerController.normalAttack = true;
        }
    }
}